package com.uphone.kingmall.adapter;

import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.blankj.utilcode.util.SizeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.app.MyApplication;
import com.uphone.kingmall.bean.ShopRecoGoodsBean;
import com.uphone.kingmall.utils.GlideUtils;

/**
 * <pre>
 *     author : radish
 *     e-mail : 15703379121@163.com
 *     time   : 2019/3/18
 *     desc   :
 * </pre>
 */
public class ShopRecoGoodsAdapter extends BaseQuickAdapter<ShopRecoGoodsBean.RecoGoodsBean, BaseViewHolder> {
    public ShopRecoGoodsAdapter() {
        super(R.layout.kingmall_item_goodslist_grid0);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopRecoGoodsBean.RecoGoodsBean item) {

        LinearLayout ll = helper.getView(R.id.ll);
        ViewGroup.LayoutParams params = ll.getLayoutParams();
        int width = (MyApplication.width - SizeUtils.dp2px(20)) / 2;
        params.width = width;
        ll.setLayoutParams(params);
        ll.setGravity(Gravity.CENTER);

        ImageView icon = helper.getView(R.id.iv_icon);
        GlideUtils.getInstance().loadCornerImage(mContext, item.getGoodsMainImg(),SizeUtils.dp2px(2), icon);
        helper.setText(R.id.tv_name, item.getGoodsName());
        helper.setText(R.id.tv_price, "¥" + item.getGoodsPrice());
        helper.setText(R.id.tv_yue_xiao, "月销" + item.getGoodsSaleNum());
    }
}
